﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Salomon/MP/Base.Master" AutoEventWireup="true" CodeBehind="FocusCreate.aspx.cs" Inherits="WebsiteAdmin.Salomon.Focus.FocusCreate" %>
<asp:Content ID="Content1" ContentPlaceHolderID="Head_Title" runat="server">新建幻灯片 - 广告</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="Head_Meta" runat="server">
</asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="Head_Css" runat="server">
<link rel='stylesheet' type='text/css' href='/css/datepicker_vista/datepicker_vista.css' />
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="Head_Script" runat="server">
	<script type="text/javascript" src="/CKFinder/CKFinder.js"></script>	
<script type="text/javascript" src="/Script/datepicker.js"></script>
<script type="text/javascript" language="javascript">
    
		var MenuViewID = 3;

		window.addEvent('domready', function() {

		    new DatePicker($('txbDepartureDateStart'), {
		        pickerClass: 'datepicker_vista',
		        format: 'Y-m-d',
		        inputOutputFormat: 'Y-m-d',
		        yearPicker: false,
		        allowEmpty: false,
		        toggleElements: $('CalendarTrigger2')
		    });
		    new DatePicker($('txbDepartureDateEnd'), {
		        pickerClass: 'datepicker_vista',
		        format: 'Y-m-d',
		        inputOutputFormat: 'Y-m-d',
		        yearPicker: false,
		        allowEmpty: false,
		        toggleElements: $('CalendarTrigger3'),
		        onSelect: function(d) {
		            var startD = $('txbDepartureDateStart').get('value');
		            var dd = d.diff(startD) - 1;
		            if (dd < -1) {
		                $('txbDepartureDateEnd').getNext('i').set('text', '相隔 ' + (-dd) + ' 天');
		            }
		            else {
		                alert('日期至少相隔1天');
		                $('txbDepartureDateEnd').getNext('i').set('text', '');
		            }
		        }
		    });

		    $('ShowLink').addEvent('click', function() {
		        BrowseServer('Images:/Ad/Focus/', 'txbImgURL', 'ShowView');

		    });

		});

		function SetFileField(fileUrl, data) {
		    $(data["selectActionData"]).value = fileUrl;
		    $(this).setProperty('src', fileUrl);
		}
		function BrowseServer(startupPath, functionData, element) {
		    var finder = new CKFinder();
		    finder.startupPath = startupPath;
		    finder.selectActionData = functionData;
		    finder.selectActionFunction = SetFileField.bind(element);
		    finder.popup();
		}
		
        function AddFocus(){
            var title = $('txtTitle').value;
            var summary = $('txtSummary').value;
            var imgURL = $('txbImgURL').value;
            var linkURL = $('txtLink').value;
            var sort =$('txtSort').value;
            var startDate = $('txbDepartureDateStart').value;
            var endDate = $('txbDepartureDateEnd').value;
            
            new Request.JSON({
                url:'Handler/Create.ashx',
                method:'post',
                data:{
                    title:title,
                    summary:summary,
                    imgURL:imgURL,
                    linkURL:linkURL,
                    sort:sort,
                    startDate:startDate,
                    endDate:endDate
                },
                onSuccess:function(json){
                    if(json.Done == 'Success'){
                        if(confirm('新增成功，返回列表？'))
                        {
                            document.location.href = '/Salomon/Focus/FocusList.aspx';
                        };
                    }else
                    {
                        alert('新增失败');
                         LightBox.remove();
                    }   
                },
                onFailure: function(xhr) {
                    alert(xhr.statusText);
                }
            }).send();
        }		
		//重置
		function Reset(){
		    $('txtTitle').innerText = '';
            $('txtSummary').innerText = '';
            $('txtImg').innerText = '';
            $('txtLink').innerText='';
            $('txtSort').innerText = 0;
            $('txbDepartureDateStart').set('value','<%=dateNow %>');
            $('txbDepartureDateEnd').set('value','<%=dateNow %>');
		}
</script>
</asp:Content>
<asp:Content ID="Content5" ContentPlaceHolderID="Body_Top" runat="server">
</asp:Content>
<asp:Content ID="Content6" ContentPlaceHolderID="Body_Content" runat="server">
     <div class="infobox">
        <h3>
            <span>新建幻灯片</span>
            <a href="/Salomon/Focus/FocusList.aspx" class="back action">返回列表</a>
        </h3>
        <div class="pd05">       
            <form id="MyForm" action="">
        <table style="width: 800px;">
            <tr>
                <td align="right" width="100">
                    标题：</td>
                <td>
                        <input type="text" id="txtTitle" name="txtTitle" style="width:300px;" value="" maxlength="40" />
                        <font color="red">*</font>
                </td>
            </tr>
            <tr>
                <td align="right" width="100">
                    简介：</td>
                <td>
                       <input type="text" id="txtSummary" name="txtSummary" style="width:400px;" value=""  maxlength="50" /> <font color="red">*&nbsp;</font></td>
            </tr>
            <tr>
                <td align="right" width="100">
                    图片：</td>
                <td>
                       <input type="text" id="txbImgURL" name="txbImgURL" style="width:450px; color:#666; background-color:#efefef; border:1px #ccc solid;" readonly="readonly" value=""  /> <font color="red">*&nbsp;</font>
                       <a id="ShowLink" style="cursor:pointer;cursor:hand;border:solid 1px;padding:0 10px 0 10px;">浏览</a>
                </td>
            </tr>
            <tr>
                <td align="right" width="100">&nbsp;</td>
                <td>
                    <div style=" width:499px; height:189px; overflow:hidden; border:1px #999 solid; background-color:#f8f8f8; clear:both;">
                       <img id="ShowView" width="499" alt="" src="/images/view.png" />
                    </div>
                    <i>图片尺寸 998 x 378，此处尺寸减半。</i><br />
                    <i>如果图片不能完全填充，请重新选择图片。</i>
                </td>
            </tr>
            <tr>
                <td align="right">
                    链接：
                </td>
                <td>
                    <input type="text" id="txtLink" style="width:400px;" value="" />
                </td>
            </tr>
            
            <tr id="TRscript">
                <td align="right">
                    排序：</td>
                <td>
                    <input id="txtSort" type="text" style="width:50px;" maxlength="3" value="0" onkeyup="value=value.replace(/[^\d]/g,''); "
                                        onbeforepaste="clipboardData.setData('text',clipboardData.getData('text').replace(/[^\d]/g,''))"/><font color="red">&nbsp;*<span id="Span1"></span></font></td>
            </tr>
            
            <tr>
            
                <td align="right"><span class="Need">日期：</span></td>
				<td>
					<input name="txbDepartureDateStart" type="text" id="txbDepartureDateStart" maxlength="50" value="<%=dateNow %>" readonly="readonly" />
					<img alt="" src="../../css/datepicker_vista/calendar.gif" id="CalendarTrigger2" />
					-
					<input name="txbDepartureDateEnd" type="text" id="txbDepartureDateEnd" maxlength="50" value="<%=dateNow %>"  readonly="readonly" />
					<img alt="" src="../../css/datepicker_vista/calendar.gif" id="CalendarTrigger3" />
					<i></i>
				</td>
            </tr>
            
           <tr>
                <td align="right">
                </td>
                <td>
                    <a href="javascript:void(0);" onclick="javascript:AddFocus();" class="bt_green fl"><span
                        class="bt_green_lft"></span><strong>提交</strong><span class="bt_green_r"></span></a>
                    <a href="javascript:void(0);" onclick="javascript:Reset();" class="bt_red fl"><span
                        class="bt_red_lft"></span><strong>重置</strong><span class="bt_red_r"></span></a>
                </td>
            </tr>
        </table>
        </form>
        </div>
    </div>

</asp:Content>
<asp:Content ID="Content7" ContentPlaceHolderID="Body_Foot" runat="server"  >
</asp:Content>